<%-- 
    Document   : ShowAllPersons
    Created on : 2024年3月24日, 上午10:35:17
    Author     : JUST
--%>

<%@page import="java.util.Date"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%       
            
            Class.forName("com.mysql.jdbc.Driver");
            Connection connection = DriverManager
                    .getConnection("jdbc:mysql://dusin.top:3306/jsp?useUnicode=true&characterEncoding=utf8"
                            ,"jsp","jsp123");
            
            String sql = "select * from person ";
            PreparedStatement st = connection.prepareStatement(sql);
            ResultSet rs = st.executeQuery();
        %>
        <h1>人员信息管理系统</h1>
        <hr/>
        <a href="addperson.jsp">新增人员</a>
        <table border="1">
            <tr><th>ID</th><th>姓名</th><th>年龄</th><th>生日</th><th>工资</th><th colspan="2">操作</th></tr>
            <%
                while(rs.next()){
                    int pid = rs.getInt(1);
                    String name = rs.getString(2);
                    int age = rs.getInt(3);
                    Date birthday = rs.getDate(4);
                    double gongzi = rs.getDouble(5);
            %>
            <tr>
                <td><%=pid%></td> 
                <td><%=name%></td>
                <td><%=age%></td>
                <td><%=birthday%></td>
                <td><%=gongzi%></td>
                <td><a href="updateperson.jsp?pid=<%=pid%>&name=<%=name%>&age=<%=age%>">修改</a></td>
                <td><a href="doremove.jsp?pid=<%=pid%>">删除</a></td>
            </tr>                
            <%    
                }
                rs.close();
                st.close();
                connection.close();
            %>
        </table>
    </body>
</html>
